package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/4/11 13:45
 * Version:1.0-SNAPSHOT
 * Description:
 */
// 此处配送的/test/*表示只要请求以/test开头
// 那么均可以访问到该Servlet
@WebServlet("/test/*")
public class TestServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String path = request.getServletPath();
        System.out.println("path:"+path);
        out.print("<h1>恭喜您,访问成功</h1>");
    }

}
